package ru.evga.inse.server.gwt.admin.client.menu;

import ru.evga.gwt.lib.common.client.place.PlaceImpl;
import ru.evga.gwt.lib.common.client.place.PlaceParamMap;
import ru.evga.inse.server.gwt.admin.client.IAdminAppFactory;
import ru.evga.inse.server.gwt.admin.client.menu.dict.city.CityListActivity;
import ru.evga.inse.server.gwt.admin.client.menu.dict.street.StreetListActivity;
import ru.evga.inse.server.gwt.admin.client.place.AdminMenuPlaceUtil;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class ContentActivityMapper implements ActivityMapper
{
    private IAdminAppFactory factory;
    
    public ContentActivityMapper(IAdminAppFactory factory)
    {
        this.factory = factory;
    }

    public Activity getActivity(Place place)
    {
        final PlaceParamMap paramMap = PlaceParamMap.makePlaceParamMap((PlaceImpl)place); 
        
        
        AdminMenuProcessor<Activity> processor = new AdminMenuProcessor<Activity>()
        {

            public void handleCity()
            {
                setResult(new CityListActivity(factory));
            }

            public void handleStreet()
            {
                setResult(new StreetListActivity(factory));
            }

        };
        
        return processor.process(AdminMenuPlaceUtil.getMenuItem(paramMap));
    }
}
